import useEcgBg from './useEcgBg'
import useEcgFont from './useEcgFont'
import useEcgLine from './useEcgLine'
import useEcgTimer from './useEcgTimer'


export default function () {
  const { draw: drawBg } = useEcgBg()
  const { draw: drawFont } = useEcgFont()
  const { draw: drawTimer } = useEcgTimer()
  const { draw: drawLine, getLineWidth } = useEcgLine()


  const drawBg_ = async (params) => {
    await drawBg({
      element: '.canvas-bg',
      lineWidth: 1,
      ppm: params.ppm,
    })
  }
  const drawFont_ = async (params) => {
    await drawFont({
      ...params,
      element: '.canvas-font',
    })
  }

  const drawTimer_ = async (params) => {
    await drawTimer({
      ...params,
      element: '.canvas-timer',
    })
  }

  const lineData = (params, initData = false) => {
    return {
      initData,
      ...params
    }
  }
  const drawLine_ = async (params, initData) => {
    const status = await drawLine(lineData(params, initData))
    return status
  }

  return {
    getLineWidth,
    drawLine_,
    drawBg_,
    drawFont_,
    drawTimer_,
    lineData
  }

}




